<template>
	<view>
		<!-- <button type="primary" @click="setStorage">存储数据</button>
		<button type="primary" @click="getStorage">获取数据</button>
		<button type="primary" @click="removeId">移除id</button> -->
		<button @click="pullDown">下拉刷新</button>
		<view>这是列表页</view>
		<view class="box-item" v-for="item in list">
			{{item}}
		</view>
		
		<button type="primary" @click="chooseImg">上传图片</button>
		<image v-for="item in imgArr" :src="item" @click="previewImg(item)"></image>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: ['前端','JAVA','UI','测试','大数据'],
				imgArr: []
			}
		},
		methods: {
			pullDown() {
				console.log('开启下拉刷新')
				uni.startPullDownRefresh()
			},
			previewImg (current) {
				uni.previewImage({
					current,
					urls: this.imgArr,
					loop: true,
					 indicator: 'default'
				})
			},
			chooseImg () {
				uni.chooseImage({
					count:5,
					success:res=>{
						this.imgArr = res.tempFilePaths
					}
				})
			}
			// setStorage() {
			// 	uni.setStorageSync('id',100)
			// },
			
			// getStorage() {
			// 	const res = uni.getStorageSync('id')
			// 	console.log(res)
			// },
			
			// removeId () {
			// 	uni.removeStorageSync('id')
			// },
		},
		onPullDownRefresh() {
			console.log('触发了下拉刷新')
			setTimeout(()=>{
				this.list = ['前端','JAVA','UI','测试','大数据']
				uni.stopPullDownRefresh()
			},2000)
		},
		onReachBottom() {
			console.log('页面触底了')
			this.list = [...this.list,...['JAVA','UI','前端','测试','大数据']]
		},
		
		onLoad(options) {
			console.log('页面加载了',options)
		},
		onShow() {
			console.log('页面显示了')
		},
		onReady() {
			console.log('页面初次渲染完成了')
		},
		onHide() {
			console.log('页面隐藏了')
		},
		
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
	
	.box-item{
			height: 100px;
			line-height: 100px;
	}

	
	
</style>
